﻿/*
 * RegExpress
 * 
 * Copyright (c) 2010, Daniel McGaughran
 * 
 * Licensed under the Apache Licence, Version 2.0 (the "Licence");
 * you may not use this file except in compliance with the Licence.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the Licence is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and
 * limitations under the Licence.
 * 
 */

using System;
using RegExpressModel;


namespace RegExpressViewModel
{
	public abstract class BaseRegexViewModel : ViewModelBase
	{

		protected BaseRegexModel BaseModel { get; set; }


		public string RegExpression
		{
			get { return BaseModel.RegExpression; }
			set
			{
				BaseModel.RegExpression = value;
				OnPropertyChanged("RegExpression");
				UpdateResults();
			}
		}


		public bool IsCaseIgnored
		{
			get { return BaseModel.IsCaseIgnored; }
			set
			{
				BaseModel.IsCaseIgnored = value;
				OnPropertyChanged("IsCaseIgnored");
				UpdateResults();
			}
		}


		public bool IsMultiLine
		{
			get { return BaseModel.IsMultiLine; }
			set
			{
				BaseModel.IsMultiLine = value;
				OnPropertyChanged("IsMultiLine");
				UpdateResults();
			}
		}


		public bool IsWhitespaceIgnored
		{
			get { return BaseModel.IsWhitespaceIgnored; }
			set
			{
				BaseModel.IsWhitespaceIgnored = value;
				OnPropertyChanged("IsWhitespaceIgnored");
				UpdateResults();
			}
		}


		public bool IsNewlineMatchedByDot
		{
			get { return BaseModel.IsNewlineMatchedByDot; }
			set
			{
				BaseModel.IsNewlineMatchedByDot = value;
				OnPropertyChanged("IsNewlineMatchedByDot");
				UpdateResults();
			}
		}


		public bool IsValid
		{
			get { return BaseModel.IsValid; }
		}



		protected virtual void UpdateResults()
		{
			OnPropertyChanged("IsValid");
		}


	}
}
